/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef __GROUP_HPP_
#define __GROUP_HPP_

#include <string>
#include <map>
#include "wx/treectrl.h"

class MuRoMainFrame;

namespace MuRo
{

class CMachine;
class CGroup;
  
typedef std::map<std::string, CGroup*>::iterator groupIter;
typedef std::map<std::string, CMachine*>::iterator machineIter;
  
  
class CGroupTreeItemData : public wxTreeItemData
{
  public:
    CGroupTreeItemData(CMachine *machine)
    :machine(machine)
    {}
    
    CMachine *machine;
};
  
/** Group
 *
 * Group is a organising class for splitting MaCI service locators and creating 
 * machine instances. It may contain subgroups or machines.
 * 
 * 
 */
class CGroup
{
  public:
    CGroup(std::string name, MuRoMainFrame *MuRo, wxTreeCtrl *treeCtrl, wxTreeItemId item);
    
    ~CGroup();
    
    CMachine* FindMachine(std::string MaCIGroup);
    
    CMachine* CreateMachine(std::string MaCIGroup);
    
    void Select(bool select);
    
    std::string GetName();
    
  private:
    std::string name;
    MuRoMainFrame *MuRo;
    wxTreeCtrl *treeCtrl;
    wxTreeItemId item;
    bool isSelected;
    
    std::map<std::string, CGroup*> groups;
    std::map<std::string, CMachine*> machines;
    
    bool AddGroup(CGroup *group);
    
    bool AddMachine(CMachine *machine);
    
    CMachine* findMachine(std::string MaCIGroup, bool createNew);
    
};
}
#endif
